package game.components;


import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Bacalá
 */
public class Tiro {

    private Image imagem = null;
    private int maxX, maxY, x, y,nTiro,nPontos;
    private int passoX = 1, passoY = 3;
    private boolean visible;

    public Tiro(int maxX, int maxY) {
        this.maxX = maxX;
        this.maxY = maxY;
        try {
            imagem = Image.createImage("/images/tiro.png");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        nTiro = 10;
        this.invisible();
    }

    public void mexe() {
        if ( y < 0) {
            this.invisible();
        }
        if (visible)
            y -= passoY;
    }

    public int getPassoX() {
        return passoX;
    }

    public void setPassoX(int passoX) {
        this.passoX = passoX;
    }

    public int getPassoY() {
        return passoY;
    }

    public void setPassoY(int passoY) {
        this.passoY = passoY;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Image getImagem() {
        return imagem;
    }

    public int getWidth() {
        return imagem.getWidth();
    }

    public int getHeight() {
        return imagem.getHeight();
    }

    public void paint(Graphics g) {
        if (this.visible)
            g.drawImage(this.getImagem(), this.getX(), this.getY(), Graphics.HCENTER | Graphics.VCENTER);
    }

    public int getMinX() {
        return this.x-this.getWidth()/2;
    }

    public int getMaxX() {
        return this.x+this.getWidth()/2;
    }
    public int getMinY() {
        return this.y-this.getHeight()/2;
    }

    public int getMaxY() {
        return this.y+this.getHeight()/2;
    }

    public void inverteX() {
        passoX=-passoX;
    }
    public void inverteY() {
        passoY=-passoY;
    }

    public void invisible() {
        visible = false;
    }
    public void visible() {
        visible = true;
    }

    public boolean isVisible() {
        return this.visible;
    }

    public void acertou(Balao b) {
        nPontos+=b.getPontos();
        nTiro +=2;
    }
    public void atirou() {
        --nTiro;
    }

    public boolean acabouTiro(){
        return nTiro == 0;
    }

    public int getnTiro() {
        return nTiro;
    }

    public void setnTiro(int nTiro) {
        this.nTiro = nTiro;
    }

    public String pontuacao() {
        return String.valueOf(nPontos);
    }

}
